package com.itheima.search.controller;

import com.itheima.common.vo.ResultVo;
import com.itheima.search.document.ArticleInfoDocument;
import com.itheima.search.dto.SearchDto;
import com.itheima.search.service.ArticleInfoSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/article/search")
public class SearchController {

    @Autowired
    private ArticleInfoSearchService articleInfoSearchService;

    @PostMapping("/search")
    public ResultVo<List<ArticleInfoDocument>> search(@RequestBody SearchDto dto){
        List<ArticleInfoDocument> articleList = articleInfoSearchService.search(dto);
        return ResultVo.ok(articleList);
    }
}
